const koa = require("koa");
const betterBody = require("koa-better-body");
const convert = require("koa-convert");
const router = require("koa-router");
const staticCache = require("koa-static-cache");
const pathlib = require("path");
let server = new koa();
server.listen(8080);

server.use(convert(betterBody({
	uploadDir:pathlib.resolve('./upload'),
	keepExtensions:true
})));


let r1 = router();
server.use(r1.routes());


r1.post("/a",async (ctx,next)=>{
	console.log(ctx.request.query);
	console.log(ctx.request.params);
	console.log(ctx.request.fields);//数据+文件信息
	console.log(ctx.request.files);//文件信息  全一些
	ctx.response.body="成功"
});

server.use(staticCache("./www"));
